package Day03.HomeWork;


import com.sun.org.apache.xml.internal.serialize.Printer;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        try {
            //新建一个文件路径
        File file=new File("./src/main/java/io");
        //建立一个低级输入流
//        FileInputStream fis=new FileInputStream(file);
        if (file.isDirectory()){//判断是否为文件
            FileFilter filter= f -> f.getName().endsWith(".java");//过滤条件
            File[] sub=file.listFiles(filter);//转成数组
      for(File subs:sub){//加强循环
          String name=subs.getName();//文件获取名字

          //将文件名导入输入流
          FileInputStream fis=new FileInputStream(("./src/main/java/io/"+name));
          //链接输入流并规定格式
          InputStreamReader isr=new InputStreamReader(fis, StandardCharsets.UTF_8);
          //缓冲
          BufferedReader br=new BufferedReader(isr);

          String mins;
          while ((mins=br.readLine())!=null){//文件末尾
              System.out.println(mins);
          }
          br.close();



      }


            }









    }catch (Exception e){
            System.out.println("有异常！！！");
        }
    }
}
